home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-23 | 2.3 KB | 97 lines | [TEXT/ALFA] |
- \
- \ Physics Units Conversions - Length - Using CGI shell 1.3
- \
- \ Ronald T. Kneusel, rkneusel@post.its.mcw.edu, 27-Oct-95
- \
- \ Last mod: 21-Mar-96
- \
- \
- \ All conversions are a table lookup. The calculation is:
- \
- \ dest value = (array[dest]/array[source]) * source value
- \
- \ where array[dest] returns the address of a floating point
- \ constant for that conversion
- \
-
- ( load CGI shell )
-
- --> shell.4th
-
- ( strings and such )
-
- $[ fname length.txt] \ template filename
-
- INT 5 " source" #field src \ fields
- INT 5 " dest" #field dest
- FP 20 " value" #field val
-
- FP 30 " answer" #object ans \ answer
- STR 30 " 1st" #object one \ 1st unit name
- STR 30 " 2nd" #object two \ 2nd unit name
-
- message[ u0 m] \ unit names
- message[ u1 angstrom]
- message[ u2 AU]
- message[ u3 cm]
- message[ u4 fm]
- message[ u5 ft]
- message[ u6 in]
- message[ u7 km]
- message[ u8 ly]
- message[ u9 micron]
- message[ u10 nmi]
- message[ u11 parsec]
- message[ u12 mi]
- message[ u13 yd]
-
- 14 array>> U \ unit names array
- u0 u1 u2 u3 u4 u5 u6 u7 u8 u9 u10 u11 u12 u13 14 U >array
-
- 2048 String>> out \ output string
-
- ( use template's array words for the conversion array )
-
- 15 array>> ang
-
- ( length constants )
-
- : >ang ( v indx -- ) ang !array ;
-
- fvariable &0 fvariable &1 fvariable &2 fvariable &3
- fvariable &4 fvariable &5 fvariable &6
- fvariable &7 fvariable &8 fvariable &9 fvariable &10
- fvariable &11 fvariable &12 fvariable &13
-
- &0 0 >ang &1 1 >ang &2 2 >ang &3 3 >ang &4 4 >ang &5 5 >ang
- &6 6 >ang &7 7 >ang &8 8 >ang &9 9 >ang &10 10 >ang
- &11 11 >ang &12 12 >ang &13 13 >ang
-
- ( setup array values - conversion constants )
-
- 1.0 &0 f! 1.0e10 &1 f! 6.685e-12 &2 f! 100.0 &3 f!
- 1.0e15 &4 f! 3.281 &5 f! 39.37 &6 f! 1.0e-3 &7 f!
- 1.057e-16 &8 f! 1.0e6 &9 f! 5.400e-4 &10 f! 6.214e-4 &12 f!
- 3.241e-17 &11 f! 1.094 &13 f!
-
- ( do the conversion )
-
- : calc ( -- ) \ calculate
- dest @val ang @array f@ src @val ang @array f@ f/
- \ array[dest]/array[source]
- val @val f* ans !val
- ;
-
- ( Apple Event handler )
-
- ,s sdoc ,s WWWΩ ae:
- <getFields>
- src @val U @array one !val \ unit names
- dest @val U @array two !val
- calc \ calculate answer
- out fname NEW template \ build reply
- out REPLY \ send reply
- bye
- ;ae
-
-